﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using MyWCF.Demo.Client.Web.Code;

namespace MyWCF.Demo.Client.Web
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class AddChatRoomMessage : HttpHandlerBase, IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            base.Init(context);
            long userId = 0;
            long chatRoomId = 0;
            if (long.TryParse(Request.Form["UserId"], out userId)
                && long.TryParse(Request.Form["ChatRoomId"], out chatRoomId)
                && string.IsNullOrEmpty(Request.Form["Message"])==false)
            {
                ChatRoomMessagesEntity entity = new ChatRoomMessagesEntity();
                entity.UserId = userId;
                entity.ChatRoomId = chatRoomId;
                entity.Message = Request.Form["Message"];

                ChatRoomManager.AddMessage(entity);
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
